package com.java1234.service;

import java.sql.Connection;
import java.sql.ResultSet;

import javax.swing.JOptionPane;

import com.java1234.dao.IBookTypeDao;
import com.java1234.dao.impl.BookTypeImpl;
import com.java1234.model.BookType;

public class BookTypeService {
	private IBookTypeDao bookTypeDao = new BookTypeImpl();

	/**
	 * 添加图书类别
	 * 
	 * @param con
	 * @param bookType
	 * @throws Exception
	 */
	public void add(Connection con, BookType bookType) throws Exception {
		int n = bookTypeDao.add(con, bookType);
		if (n == 1) {
			JOptionPane.showMessageDialog(null, "图书类别添加成功！");
		} else {
			JOptionPane.showMessageDialog(null, "图书类别添加失败！");
		}

	}

	/**
	 * 查询图书类别集合
	 * 
	 * @param con
	 * @param bookType
	 * @throws Exception
	 */
	public void list(Connection con, BookType bookType) throws Exception {
		bookTypeDao.list(con, bookType);
	}

	/**
	 * 删除图书类别
	 * 
	 * @param con
	 * @param id
	 * @throws Exception
	 */
	public void delete(Connection con, String id) throws Exception {
		bookTypeDao.delete(con, id);

	}

	/**
	 * 更新图书类别
	 * 
	 * @param con
	 * @param bookType
	 * @throws Exception
	 */
	public void update(Connection con, BookType bookType) throws Exception {
		bookTypeDao.update(con, bookType);
	}
}
